﻿namespace Ecos.GroceryList.Domain
{
    public class Product
    {
        private string _item;

        public static Product From(string newItem)
        {
            var product = new Product {_item = newItem};

            return product;
        }
        public override bool Equals(object obj)
        {
            return Equals(obj as Product);
        }


        public bool Equals(Product other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(other._item, _item);
        }

        public override int GetHashCode()
        {
            return (_item != null ? _item.GetHashCode() : 0);
        }

        public override string ToString()
        {
            return _item;
        }
    }
}